/*
MIT License

Copyright(c) 2019-2020 megai2

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/
#include "stdafx.h"

typedef enum d912pxy_com_route_table {
	PXY_COM_ROUTE_DEVICE = 0,
	PXY_COM_ROUTE_RESOURCE = 1,
	PXY_COM_ROUTE_VBUF = 2,
	PXY_COM_ROUTE_IBUF,
	PXY_COM_ROUTE_SURFACE,
	PXY_COM_ROUTE_QUERY,
	PXY_COM_ROUTE_QUERY_OCC,
	PXY_COM_ROUTE_BASE_TEXTURE,
	PXY_COM_ROUTE_TEXTURE_2D,
	PXY_COM_ROUTE_TEXTURE_3D,
	PXY_COM_ROUTE_TEXTURE_CUBE,
	PXY_COM_ROUTE_VDECL,	
	PXY_COM_ROUTE_SHADER,
	PXY_COM_ROUTE_SWAPCHAIN,
	PXY_COM_ROUTE_SURFACE_LAYER,
	PXY_COM_ROUTE_SBLOCK,
	PXY_COM_ROUTE_EMPTY,
	PXY_COM_ROUTE_COUNT
} d912pxy_com_route_table;

#define PXY_INNER_MAX_COM_ROUTE_TABLE_LENGTH 256

typedef enum d912pxy_com_route_method_unk {
	PXY_COM_METHOD_UNK_QUERY_INTERFACE = 0,
	PXY_COM_METHOD_UNK_ADDREF = 1,
	PXY_COM_METHOD_UNK_RELEASE = 2,
} d912pxy_com_route_method_unk;

typedef enum d912pxy_com_route_method_dev {
	PXY_COM_METHOD_DEV_TESTCOOPERATIVELEVEL = 3,
	PXY_COM_METHOD_DEV_GETAVAILABLETEXTUREMEM,
	PXY_COM_METHOD_DEV_EVICTMANAGEDRESOURCES,
	PXY_COM_METHOD_DEV_GETDIRECT3D,
	PXY_COM_METHOD_DEV_GETDEVICECAPS,
	PXY_COM_METHOD_DEV_GETDISPLAYMODE,
	PXY_COM_METHOD_DEV_GETCREATIONPARAMETERS,
	PXY_COM_METHOD_DEV_SETCURSORPROPERTIES,
	PXY_COM_METHOD_DEV_SETCURSORPOSITION,
	PXY_COM_METHOD_DEV_SHOWCURSOR,
	PXY_COM_METHOD_DEV_CREATEADDITIONALSWAPCHAIN,
	PXY_COM_METHOD_DEV_GETSWAPCHAIN,
	PXY_COM_METHOD_DEV_GETNUMBEROFSWAPCHAIN,
	PXY_COM_METHOD_DEV_RESET,
	PXY_COM_METHOD_DEV_PRESENT,
	PXY_COM_METHOD_DEV_GETBACKBUFFER,
	PXY_COM_METHOD_DEV_GETRASTERSTATUS,
	PXY_COM_METHOD_DEV_SETDIALOGBOXMODE,
	PXY_COM_METHOD_DEV_SETGAMMARAMP,
	PXY_COM_METHOD_DEV_GETGAMMARAMP,
	PXY_COM_METHOD_DEV_CREATETEXTURE,
	PXY_COM_METHOD_DEV_CREATEVOLUMETEXTURE,
	PXY_COM_METHOD_DEV_CREATECUBETEXTURE,
	PXY_COM_METHOD_DEV_CREATEVERTEXBUFFER,
	PXY_COM_METHOD_DEV_CREATEINDEXBUFFER,
	PXY_COM_METHOD_DEV_CREATERENDERTARGET,
	PXY_COM_METHOD_DEV_CREATEDEPTHSTENCILSURFACE,
	PXY_COM_METHOD_DEV_UPDATESURFACE,
	PXY_COM_METHOD_DEV_UPDATETEXTURE,
	PXY_COM_METHOD_DEV_GETRENDERTARGETDATA,
	PXY_COM_METHOD_DEV_GETFRONTBUFFERDATA,
	PXY_COM_METHOD_DEV_STRETCHRECT,
	PXY_COM_METHOD_DEV_COLORFILL,
	PXY_COM_METHOD_DEV_CREATEOFFSCREENPLAINSURFACE,
	PXY_COM_METHOD_DEV_SETRENDERTARGET,
	PXY_COM_METHOD_DEV_GETRENDERTARGET,
	PXY_COM_METHOD_DEV_SETDEPTHSTENCILSURFACE,
	PXY_COM_METHOD_DEV_GETDEPTHSTENCILSURFACE,
	PXY_COM_METHOD_DEV_BEGINSCENE,
	PXY_COM_METHOD_DEV_ENDSCENE,
	PXY_COM_METHOD_DEV_CLEAR,
	PXY_COM_METHOD_DEV_SETTRANSFORM,
	PXY_COM_METHOD_DEV_GETTRANSFORM,
	PXY_COM_METHOD_DEV_MULTIPLYTRANSFORM,
	PXY_COM_METHOD_DEV_SETVIEWPORT,
	PXY_COM_METHOD_DEV_GETVIEWPORT,
	PXY_COM_METHOD_DEV_SETMATERIAL,
	PXY_COM_METHOD_DEV_GETMATERIAL,
	PXY_COM_METHOD_DEV_SETLIGHT,
	PXY_COM_METHOD_DEV_GETLIGHT,
	PXY_COM_METHOD_DEV_LIGHTENABLE,
	PXY_COM_METHOD_DEV_GETLIGHTENABLE,
	PXY_COM_METHOD_DEV_SETCLIPPLANE,
	PXY_COM_METHOD_DEV_GETCLIPPLANE,
	PXY_COM_METHOD_DEV_SETRENDERSTATE,
	PXY_COM_METHOD_DEV_GETRENDERSTATE,
	PXY_COM_METHOD_DEV_CREATESTATEBLOCK,
	PXY_COM_METHOD_DEV_BEGINSTATEBLOCK,
	PXY_COM_METHOD_DEV_ENDSTATEBLOCK,
	PXY_COM_METHOD_DEV_SETCLIPSTATUS,
	PXY_COM_METHOD_DEV_GETCLIPSTATUS,
	PXY_COM_METHOD_DEV_GETTEXTURE,
	PXY_COM_METHOD_DEV_SETTEXTURE,
	PXY_COM_METHOD_DEV_GETTEXTURESTAGESTATE,
	PXY_COM_METHOD_DEV_SETTEXTURESTAGESTATE,
	PXY_COM_METHOD_DEV_GETSAMPLERSTATE,
	PXY_COM_METHOD_DEV_SETSAMPLERSTATE,
	PXY_COM_METHOD_DEV_VALIDATEDEVICE,
	PXY_COM_METHOD_DEV_SETPALETTEENTRIES,
	PXY_COM_METHOD_DEV_GETPALETTEENTRIES,
	PXY_COM_METHOD_DEV_SETCURRENTTEXTUREPALETTE,
	PXY_COM_METHOD_DEV_GETCURRENTTEXTUREPALETTE,
	PXY_COM_METHOD_DEV_SETSCISSORRECT,
	PXY_COM_METHOD_DEV_GETSCISSORRECT,
	PXY_COM_METHOD_DEV_SETSOFTWAREVERTEXPROCESSING,
	PXY_COM_METHOD_DEV_GETSOFTWAREVERTEXPROCESSING,
	PXY_COM_METHOD_DEV_SETNPATCHMODE,
	PXY_COM_METHOD_DEV_GETNPATCHMODE,
	PXY_COM_METHOD_DEV_DRAWPRIMITIVE,
	PXY_COM_METHOD_DEV_DRAWINDEXEDPRIMITIVE,
	PXY_COM_METHOD_DEV_DRAWPRIMITIVEUP,
	PXY_COM_METHOD_DEV_DRAWINDEXEDPRIMITIVEUP,
	PXY_COM_METHOD_DEV_PROCESSVERTICES,
	PXY_COM_METHOD_DEV_CREATEVERTEXDECLARATION,
	PXY_COM_METHOD_DEV_SETVERTEXDECLARATION,
	PXY_COM_METHOD_DEV_GETVERTEXDECLARATION,
	PXY_COM_METHOD_DEV_SETFVF,
	PXY_COM_METHOD_DEV_GETFVF,
	PXY_COM_METHOD_DEV_CREATEVERTEXSHADER,
	PXY_COM_METHOD_DEV_SETVERTEXSHADER,
	PXY_COM_METHOD_DEV_GETVERTEXSHADER,
	PXY_COM_METHOD_DEV_SETVERTEXSHADERCONSTANTF,
	PXY_COM_METHOD_DEV_GETVERTEXSHADERCONSTANTF,
	PXY_COM_METHOD_DEV_SETVERTEXSHADERCONSTANTI,
	PXY_COM_METHOD_DEV_GETVERTEXSHADERCONSTANTI,
	PXY_COM_METHOD_DEV_SETVERTEXSHADERCONSTANTB,
	PXY_COM_METHOD_DEV_GETVERTEXSHADERCONSTANTB,
	PXY_COM_METHOD_DEV_SETSTREAMSOURCE,
	PXY_COM_METHOD_DEV_GETSTREAMSOURCE,
	PXY_COM_METHOD_DEV_SETSTREAMSOURCEFREQ,
	PXY_COM_METHOD_DEV_GETSTREAMSOURCEFREQ,
	PXY_COM_METHOD_DEV_SETINDICES,
	PXY_COM_METHOD_DEV_GETINDICES,
	PXY_COM_METHOD_DEV_CREATEPIXELSHADER,
	PXY_COM_METHOD_DEV_SETPIXELSHADER,
	PXY_COM_METHOD_DEV_GETPIXELSHADER,
	PXY_COM_METHOD_DEV_SETPIXELSHADERCONSTANTF,
	PXY_COM_METHOD_DEV_GETPIXELSHADERCONSTANTF,
	PXY_COM_METHOD_DEV_SETPIXELSHADERCONSTANTI,
	PXY_COM_METHOD_DEV_GETPIXELSHADERCONSTANTI,
	PXY_COM_METHOD_DEV_SETPIXELSHADERCONSTANTB,
	PXY_COM_METHOD_DEV_GETPIXELSHADERCONSTANTB,
	PXY_COM_METHOD_DEV_DRAWRECTPATCH,
	PXY_COM_METHOD_DEV_DRAWTRIPATCH,
	PXY_COM_METHOD_DEV_DELETEPATCH,
	PXY_COM_METHOD_DEV_CREATEQUERY
} d912pxy_com_route_method_dev;

typedef enum d912pxy_com_route_method_resource {	
	PXY_COM_METHOD_RESOURCE_GETDEVICE = 3,
	PXY_COM_METHOD_RESOURCE_SETPRIVATEDATA,
	PXY_COM_METHOD_RESOURCE_GETPRIVATEDATA,
	PXY_COM_METHOD_RESOURCE_FREEPRIVATEDATA,
	PXY_COM_METHOD_RESOURCE_SETPRIORITY,
	PXY_COM_METHOD_RESOURCE_GETPRIORITY,
	PXY_COM_METHOD_RESOURCE_PRELOAD,
	PXY_COM_METHOD_RESOURCE_GETTYPE
} d912pxy_com_route_method_resource;

typedef enum d912pxy_com_route_method_vstream {
	PXY_COM_METHOD_VSTREAM_LOCK = 11,
	PXY_COM_METHOD_VSTREAM_UNLOCK,
	PXY_COM_METHOD_VSTREAM_GETDESC
} d912pxy_com_route_method_vstream;

typedef enum d912pxy_com_route_method_surface {
	PXY_COM_METHOD_SURFACE_GETCONTAINER = 11,
	PXY_COM_METHOD_SURFACE_GETDESC,
	PXY_COM_METHOD_SURFACE_LOCKRECT,
	PXY_COM_METHOD_SURFACE_UNLOCKRECT,
	PXY_COM_METHOD_SURFACE_GETDC,
	PXY_COM_METHOD_SURFACE_RELEASEDC
} d912pxy_com_route_method_surface;

typedef enum d912pxy_com_route_method_query {
	PXY_COM_METHOD_QUERY_GETDEVICE = 3,
	PXY_COM_METHOD_QUERY_GETTYPE,
	PXY_COM_METHOD_QUERY_GETDATASIZE,
	PXY_COM_METHOD_QUERY_ISSUE,
	PXY_COM_METHOD_QUERY_GETDATA
} d912pxy_com_route_method_query;

typedef enum d912pxy_com_route_method_basetexture {
	PXY_COM_METHOD_BASETEXTURE_SETLOD = 11,
	PXY_COM_METHOD_BASETEXTURE_GETLOD,
	PXY_COM_METHOD_BASETEXTURE_GETLEVELCOUNT,
	PXY_COM_METHOD_BASETEXTURE_SETAUTOGENFILTERTYPE,
	PXY_COM_METHOD_BASETEXTURE_GETAUTOGENFILTERTYPE,
	PXY_COM_METHOD_BASETEXTURE_GENERATEMIPSUBLEVELS
} d912pxy_com_route_method_basetexture;

typedef enum d912pxy_com_route_method_texture {
	PXY_COM_METHOD_TEXTURE_GETLEVELDESC = 17,
	PXY_COM_METHOD_TEXTURE_GETSURFACELEVEL,
	PXY_COM_METHOD_TEXTURE_LOCKRECT,
	PXY_COM_METHOD_TEXTURE_UNLOCKRECT,
	PXY_COM_METHOD_TEXTURE_ADDDIRTYRECT
} d912pxy_com_route_method_texture;

typedef enum d912pxy_com_route_method_vdecl {
	PXY_COM_METHOD_VDECL_GETDEVICE = 3,
	PXY_COM_METHOD_VDECL_GETDECLARATION
} d912pxy_com_route_method_vdecl;

typedef enum d912pxy_com_route_method_shader {
	PXY_COM_METHOD_SHADER_GETDEVICE = 3,
	PXY_COM_METHOD_SHADER_GETFUNCTION
} d912pxy_com_route_method_shader;

typedef enum d912pxy_com_route_method_swapchain {
	PXY_COM_METHOD_SWAPCHAIN_PRESENT = 3,
	PXY_COM_METHOD_SWAPCHAIN_GETFRONTBUFFERDATA,
	PXY_COM_METHOD_SWAPCHAIN_GETBACKBUFFER,
	PXY_COM_METHOD_SWAPCHAIN_GETRASTERSTATUS,
	PXY_COM_METHOD_SWAPCHAIN_GETDISPLAYMODE,
	PXY_COM_METHOD_SWAPCHAIN_GETDEVICE,
	PXY_COM_METHOD_SWAPCHAIN_GETPRESENTPARAMETERS
} d912pxy_com_route_method_swapchain;

typedef enum d912pxy_com_route_method_sblock {
	PXY_COM_METHOD_SBLOCK_GETDEVICE = 3,
	PXY_COM_METHOD_SBLOCK_CAPTURE = 4,
	PXY_COM_METHOD_SBLOCK_APPLY
} d912pxy_com_route_method_sblock;

typedef enum d912pxy_com_route_empty {
	PXY_COM_METHOD_EMPTY_NON_USED = 3
} d912pxy_com_route_empty;

void d912pxy_com_route_set(d912pxy_com_route_table table, UINT32 index, void* func);
void* d912pxy_com_route_get_vtable(d912pxy_com_route_table table);

void d912pxy_com_route_init_default();